package com.sean.test

import com.xmh.code.PingApplication
import com.xmh.code.mq.consumer.RocketMQConsumer
import com.xmh.code.repository.PingRecordRepository
import com.xmh.code.service.PingService
import org.apache.rocketmq.spring.core.RocketMQTemplate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.web.reactive.function.client.WebClient
import spock.lang.Specification

@SpringBootTest(classes = [PingApplication], properties = [
        "rocketmq.producer.group=ConsumerErrorSpecProducer",
        "rocketmq.consumer.group=ConsumerErrorSpecConsumer",
        "pong.api=/test"
])
class ConsumerSendSpec extends Specification {

    @Autowired
    RocketMQConsumer myService
    @Autowired
    private WebClient webClient;
    @MockBean
    private PingService pingService;
    @MockBean
    private PingRecordRepository repository;
    @MockBean
    private RocketMQTemplate rocketMQTemplate;

    def "onMessage - send message to pong server and save record with Success"() {
        given:
        def input = "test input"
        when:
        myService.onMessage(input)
        then: "Verify"
        1 == 1
    }

    def "onMessage - send message to pong server and save record with 429"() {
        given:
        def input = "test input"
        when:
        myService.onMessage(input)
        then: "Verify"
        1 == 1
    }
}
